import React, { Component } from 'react';
// 1. 引入类型校验库
import PropTypes from "prop-types"
class Demo extends React.Component{
  render(){
    return <div>
      <h1>Demo 组件</h1>
      {
        this.props.colors.map(v=><span key={v.key}>{v.name}</span>)
      }
    </div>
  }
}
// 2. 添加校验规则
Demo.propTypes = {
  colors:PropTypes.array
}
class App extends Component {
  render() {
    return (
      <div>
        <Demo colors={19}></Demo>
      </div>
    );
  }
}

export default App;
